package com.chenfan.process.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.chenfan.process.entity.dto.ApprovalTemplateQueryDTO;
import com.chenfan.process.entity.po.ApprovalTemplatePo;

import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author K
 * @date 2021/3/17
 */
public interface ApprovalTemplateService extends IService<ApprovalTemplatePo> {

    List<ApprovalTemplatePo> listAvailableApproval();

    List<ApprovalTemplatePo> listAvailableApproval(List<Long> approvalIdList);

    Page<ApprovalTemplatePo> pageApprovalTemplate(Integer pageNum, Integer pageSize, ApprovalTemplateQueryDTO template);

    ApprovalTemplatePo findByTitle(String title);

    ApprovalTemplatePo getByCode(String code);

    List<ApprovalTemplatePo> listByCode(Collection<Long> codeList);
    default List<ApprovalTemplatePo> listByCodes(Collection<String> codeList) {
        List<Long> codes = codeList.stream().map(e -> Long.valueOf(e)).collect(Collectors.toList());
        return listByCode(codes);
    }

    Integer statisticsNumber();
}
